import time
import requests


def group_8(ehrid,headers_8,DOMAIN):
    try:
        dict_group_8 = {"健康分类": ""}
        url_group_8 = F"{DOMAIN}/phis/app/svc/ehrestimate"
        data = {
            "search_EQ_ehrId": f"{ehrid}",
            "_dch": f"{time.time()}".replace(".", "")[:13],
        }
        response_8 = requests.post(url_group_8, data=data, headers=headers_8)

        list_jiakangfenlei = []
        for info in response_8.json():
            dict_info = {}
            dict_info["记录日期"] = info["dateCreated"]
            fenlei = info["ehrClassify"]
            if fenlei == "1":
                dict_info["健康分类"] = "健康"
            elif fenlei == "2":
                dict_info["健康分类"] = "高危"
            elif fenlei == "3":
                dict_info["健康分类"] = "慢病"
            else:
                dict_info["健康分类"] = "其他"


            dict_info["记录人"] = info["estCreator"]

            list_jiakangfenlei.append(dict_info)

        dict_group_8["健康分类"] = list_jiakangfenlei
        if dict_group_8["健康分类"] == []:
            dict_group_8["健康分类"] = "无"

    except:
        dict_group_8["健康分类"] = "获取失败"
    print("问题没有在8",dict_group_8)
    return dict_group_8

if __name__ == '__main__':
    headers_8 = {
        "accept": "application/json",
        "accept-encoding": "gzip, deflate",
        "accept-language": "zh-CN,zh;q=0.9",
        "connection": "keep-alive",
        "content-length": "71",
        "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
        "cookie": "JSESSIONID=ED2F7D698955BF7C44C0C0EE53A787BD",
        "host": "10.216.11.24:8306",
        "origin": "http://10.216.11.24:8306",
        "referer": "http://10.216.11.24:8306/phis/app/ehr/update/1244783,,,false",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
        "x-requested-with": "XMLHttpRequest",
    }
    dict_group_8 = group_8("90c956aa-b78e-41e7-aca7-7f18e48e65a4",headers_8)